

public class ListNode {
    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
    }

    @Override
    public String toString() {
        return val+"->"+next;
    }


    public static ListNode create(int... val) {
        ListNode head = null;
        ListNode next = null;
        for (int i = val.length -1; i >= 0; i--) {
            head = new ListNode(val[i]);
            head.next = next;
            next = head;
        }
        return head;
    }
}